# First stage: complete build environment
FROM  maven:3.9-amazoncorretto-8-debian AS builder
WORKDIR /app
RUN apt update && apt install -y git
RUN git clone https://gitee.com/heichong/ruoyi-radius.git
WORKDIR /app/ruoyi-radius
RUN mvn clean package -Dmaven.test.skip=true
RUN ls -al

# Second stage: run app
FROM openjdk:8-jre
MAINTAINER panweilei
RUN mkdir -p /home/ruoyi/server/logs
WORKDIR /home/ruoyi/server
ENV SERVER_PORT=8090 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS=""
EXPOSE ${SERVER_PORT}
COPY --from=builder /app/ruoyi-radius/ruoyi-admin/target/*.jar ./app.jar
ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \
           -XX:+HeapDumpOnOutOfMemoryError ${JAVA_OPTS} \
           -jar app.jar
